package com.example.api.mall.config;

import io.minio.MinioClient;
import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Redisson分布式锁
 * @author xw.s
 * 2021-04-07
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "redisson")
public class RedissonConfig {
    private String address;
    private Long timeout;

    @Bean
    public RedissonClient redissonClient(){
        Config config = new Config();
        config.useSingleServer().setAddress(address);
        config.setLockWatchdogTimeout(timeout);//设置锁的自动过期时间 单位ms
        return Redisson.create(config);
    }

}